package com.ph.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ph.feign.GroupFeign;
import com.ph.mapper.KeepProjectMapper;
import com.ph.pojo.KeepProject;
import com.ph.pojo.Result;
import com.ph.pojo.User;
import com.ph.service.KeepProjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service
public class KeepProjectServiceImpl extends ServiceImpl<KeepProjectMapper, KeepProject> implements KeepProjectService {
    @Autowired
    private GroupFeign groupFeign;
    @Override
    public List<KeepProject> findAll(Integer keepGroupId) {
        List<KeepProject> keepProjects = baseMapper.findAll(keepGroupId);
        for(KeepProject keepProject: keepProjects){
            if(keepProject.getProjectUserIds()!=null && keepProject.getProjectUserIds().size() > 0 ){
                Result<List<User>> result = groupFeign.keepFindById(keepProject.getProjectUserIds());
                keepProject.setProjectUsers(result.getData());
            }

        }
        log.info("keepProjects:{}",keepProjects);
        return keepProjects;
    }
}
